package com.lollipop.rabbitmqspringboot.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: Lollipop
 * @Date: 2021-10-10 17:26
 * @Description: RabbitMQ的延时插件配置类（由于没有当前使用的RabbitMQ没有安装延迟插件，先注释掉避免项目启动报错）
 */
//@Configuration
//public class DelayedQueueConfig {
//    /**
//     * 队列名称
//     */
//    public static final String DELAYED_QUEUE_NAME = "delayed.queue";
//    /**
//     * 交换机
//     */
//    public static final String DELAYED_EXCHANGE_NAME = "delayed.exchange";
//    /**
//     * routing-key
//     */
//    public static final String DELAYED_QUEUE_ROUTING_KEY = "delayed.routingkey";
//
//    /**
//     * 声明队列
//     *
//     * @return
//     */
//    @Bean
//    public Queue delayedQueue() {
//        return new Queue(DELAYED_QUEUE_NAME);
//    }
//
//    /**
//     * 声明延迟交换机
//     *
//     * @return
//     */
//    @Bean
//    public CustomExchange customDelayedExchange() {
//        Map<String, Object> args = new HashMap<>();
//        args.put("x-delayed-type", "direct");
//        return new CustomExchange(DELAYED_EXCHANGE_NAME, "x-delayed-message", true, false, args);
//    }
//
//    /**
//     * 将以上声明的队列和交换机绑定
//     *
//     * @param delayedQueue
//     * @param customDelayedExchange
//     * @return
//     */
//    @Bean
//    public Binding delayedQueueBindingDelayedExchange(Queue delayedQueue, CustomExchange customDelayedExchange) {
//        return BindingBuilder.bind(delayedQueue).to(customDelayedExchange).with(DELAYED_QUEUE_ROUTING_KEY).noargs();
//    }
//
//}
